import pdb
import serial
import sys

p = serial.Serial(port=9, baudrate=1200, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=5, writeTimeout=5,  xonxoff=0, rtscts=0)


print p.portstr
print p.readable(), p.writable()
print p.inWaiting()

while True:
    sys.stdout.write('data: "')
    d = p.readline()
    for i in d: sys.stdout.write(str(ord(i)))
    sys.stdout.write('"\n')
    sys.stdout.flush()

p.close()
